Resource download method, electronic device, and apparatus

ABSTRACT

A method includes initiating, by an electronic device, a first request to a server, receiving, by the electronic device, a packet that is generated by the server based on the first request and that is returned by the server, where the packet includes an entity data part corresponding to the first request. The method further includes, when it is determined that the entity data part of the packet is a download resource, writing, by the electronic device, the download resource into a first storage area of the electronic device. The method further includes notifying, by the electronic device, a download manager in the electronic device. The method further includes reading, by the download manager, the download resource from the first storage area, and storing the download resource into a second storage area of the electronic device.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a continuation application of U.S. patent application Ser. No. 15/503,126, filed on Feb. 10, 2017, which is a national stage application of International Application No. PCT/CN2014/085306, filed on Aug. 27, 2014. All of the aforementioned applications are hereby incorporated by reference in their entireties.

TECHNICAL FIELD

The present disclosure relates to the field of electronic technologies, and in particular, to a resource download method, an electronic device, and an apparatus.

BACKGROUND

Currently, an Android package (APK) named DownloadProvider (a download manager) is built in an Android system, and is used to download a resource such as audio, a video, text, and an installation package.

After a user enters a website address in a client (such as a browser), the client sends a GET request to a server based on the hypertext transfer protocol (HTTP), to obtain data from a network. The GET request method requests the server to put, into an entity data part of a packet, a resource located using a uniform resource locator (URL), to return to the client. When receiving packet header information of the packet, the client parses the packet header information to determine whether the resource requested by the GET request is a download resource or a resource in another form, such as a web page, that is, determine whether the entity data part of the packet is a download resource or a resource in another form, such as a web page resource. When determining that the entity data part is a download resource, the client stops resource loading, and writes a download link address of the download resource into a download record database corresponding to DownloadProvider. After detecting a download request in the download record database, DownloadProvider retrieves the to-be-downloaded record, and DownloadProvider sends a GET request to the server according to the download link address in the download record. The server responds to the GET request of DownloadProvider, and the server puts the download resource into the entity data part to return to DownloadProvider. When receiving the packet header information, DownloadProvider parses the packet header information to determine whether the resource requested by the GET request is a download resource. If the resource is a download resource, the download resource is directly downloaded from the server to a storage area using DownloadProvider.

It can be learned that, in other approaches, if a resource is downloaded using a request that is sent by a client and that is used to obtain a download resource, two GET requests need to be initiated to a server in an entire process in which the client requests to download the resource, and the server needs to make two responses to an electronic device, where at least packet header information needs to be returned in the two responses, to determine whether the requested resource is a download resource. The two GET requests and the two responses cause problems of increased network load and a traffic waste.

SUMMARY

Embodiments of the present disclosure provide a resource download method, an electronic device, and an apparatus, which are used to resolve technical problems of increased network load and a traffic waste that are caused in other approaches.

According to a first aspect, an embodiment of the present disclosure provides a resource download method, where the method is applied to an electronic device, and includes initiating, by a client module in the electronic device, a first request to a server, receiving, by the client module, a packet that is generated by the server based on the first request and that is returned by the server, where the packet includes an entity data part corresponding to the first request, when it is determined that the entity data part of the packet is a download resource, writing, by the client module, the download resource into a first storage area of the electronic device, and notifying, by the client module, a download management module in the electronic device, and reading, by the download management module, the download resource from the first storage area, and storing the download resource into a second storage area of the electronic device.

With reference to the first aspect, in a first possible implementation manner, the electronic device further includes a cache service module, the writing, by the client module, the download resource into a first storage area of the electronic device includes writing, by the client module, the download resource into the first storage area using the cache service module, and the reading, by the download management module, the download resource from the first storage area, and storing the download resource into a second storage area of the electronic device includes reading, by the download management module, the download resource from the first storage area using the cache service module, and storing, by the download management module, the download resource into the second storage area.

With reference to the first possible implementation manner of the first aspect, in a second possible implementation manner, the packet further includes packet header information, and the writing, by the client module, the download resource into the first storage area using the cache service module includes, when the client module receives the packet header information, determining whether the entity data part is a download resource according to the packet header information, when it is determined that the entity data part is a download resource, receiving, by the client module, the entity data part, and writing, by the client module, data of the received entity data part into the first storage area using the cache service module such that the client module writes the download resource into the first storage area.

With reference to the second possible implementation manner of the first aspect, in a third possible implementation manner, the notifying, by the client module, a download management module in the electronic device includes generating, by the client module, first identification information according to the packet header information and a uniform resource locator URL of the download resource, and writing, by the client module, the first identification information into a download record database associated with the download management module, where the first identification information is used by the download management module to obtain a download request corresponding to the download resource.

With reference to the third possible implementation manner of the first aspect, in a fourth possible implementation manner, the reading, by the download management module, the download resource from the first storage area using the cache service module includes responding to, by the download management module, the download request, and querying, in the cache service module, identification information that matches the first identification information, where the download resource is indexed in the cache service module using second identification information, and when finding the second identification information that matches the first identification information, reading, from the first storage area by the download management module using the cache service module, the download resource corresponding to the second identification information.

With reference to the fourth possible implementation manner of the first aspect, in a fifth possible implementation manner, after the writing, by the client module, the first identification information into a download record database associated with the download management module, the method further includes, when the download management module fails to find, in the cache service module, the identification information that matches the first identification information, determining the URL from the first identification information, where the URL is used by the server to obtain the download resource, and sending, by the download management module according to the URL, a second request to the server, where the second request is used to request the server to return the download resource to the download management module.

According to a second aspect, an embodiment of the present disclosure provides an electronic device, including a first sending unit configured to control a client module in the electronic device to initiate a first request to a server, a receiving unit configured to control the client module to receive a packet that is generated by the server based on the first request and that is returned by the server, where the packet includes an entity data part corresponding to the first request, a write unit configured to, when determining that the entity data part of the packet is a download resource, control the client module to write the download resource into a first storage area of the electronic device, and a read unit configured to control the client module to notify a download management module in the electronic device, and control the download management module to read the download resource from the first storage area and store the download resource into a second storage area of the electronic device.

With reference to the second aspect, in a first possible implementation manner, when the electronic device further includes a cache service module, the write unit is configured to control the client module to write, using the cache service module, the download resource into the first storage area, and the read unit is configured to control the download management module to read, using the cache service module, the download resource from the first storage area, and control the download management module to store the download resource into the second storage area.

With reference to the first possible implementation manner of the second aspect, in a second possible implementation manner, the packet further includes packet header information, and the write unit is configured to, when the client module receives the packet header information, determine whether the entity data part is a download resource according to the packet header information, when determining that the entity data part is a download resource, control the client module to receive the entity data part, and control the client module to write, using the cache service module, data of the received entity data part into the first storage area such that the client module writes the download resource into the first storage area.

With reference to the second possible implementation manner of the second aspect, in a third possible implementation manner, the write unit is further configured to control the client module to generate, according to the packet header information and a uniform resource locator URL of the download resource, first identification information, and control the client module to write the first identification information into a download record database associated with the download management module, where the first identification information is used by the download management module to obtain a download request corresponding to the download resource.

With reference to the third possible implementation manner of the second aspect, in a fourth possible implementation manner, the read unit is configured to control the download management module to respond to the download request, and query, in the cache service module, identification information that matches the first identification information, where the download resource is indexed in the cache service module using second identification information, and when the download management module finds the second identification information that matches the first identification information, control the download management module to read, from the first storage area using the cache service module, the download resource corresponding to the second identification information.

With reference to the fourth possible implementation manner of the second aspect, in a fifth possible implementation manner, the electronic device further includes a determining unit configured to, when the download management module fails to find, in the cache service module, the identification information that matches the first identification information, determine the URL from the first identification information, where the URL is used by the server to obtain the download resource, and a second sending unit configured to control the download management module to send, according to the URL, a second request to the server, where the second request is used to request the server to return the download resource to the download management module.

According to a third aspect, an embodiment of the present disclosure provides an electronic device, including a transceiver, an input apparatus, and a processor, where the processor is configured to control a client module in the electronic device to initiate a first request to a server, receive a packet that is generated by the server based on the first request and that is returned by the server, where the packet includes an entity data part corresponding to the first request, when it is determined that the entity data part of the packet is a download resource, write the download resource into a first storage area of the electronic device, and notify a download management module in the electronic device, and the processor is further configured to control the download management module to read the download resource from the first storage area and store the download resource into a second storage area of the electronic device.

With reference to the third aspect, in a first possible implementation manner, when the electronic device further includes a cache service module, the processor is configured to control the client module to write, using the cache service module, the download resource into the first storage area, and the processor is configured to control the download management module to read, using the cache service module, the download resource from the first storage area, and store the download resource into the second storage area.

With reference to the first possible implementation manner of the third aspect, in a second possible implementation manner, the packet further includes packet header information, and the processor is further configured to control the client module to, when receiving the packet header information, determine, according to the packet header information, whether the entity data part is a download resource, when it is determined that the entity data part is a download resource, receive the entity data part, and write, using the cache service module, data of the received entity data part into the first storage area such that the client module writes the download resource into the first storage area.

With reference to the second possible implementation manner of the third aspect, in a third possible implementation manner, the processor is configured to control the client to generate first identification information according to the packet header information and a uniform resource locator URL of the download resource, and write the first identification information into a download record database associated with the download management module, where the first identification information is used by the download management module to obtain a download request corresponding to the download resource.

With reference to the third possible implementation manner of the third aspect, in a fourth possible implementation manner, the processor is configured to control the download management module to respond to the download request, and query, in the cache service module, identification information that matches the first identification information, where the download resource is indexed in the cache service module using second identification information, and when finding the second identification information that matches the first identification information, read, from the first storage area using the cache service module, the download resource corresponding to the second identification information.

With reference to the fourth possible implementation manner of the third aspect, in a fifth possible implementation manner, the processor is further configured to control the download management module to, when the download management module fails to find, in the cache service module, the identification information that matches the first identification information, determine the URL from the first identification information, where the URL is used by the server to obtain the download resource, and send, according to the URL, a second request to the server, where the second request is used to request the server to return the download resource to the download management module.

Technical solutions provided in the embodiments of the present disclosure have at least the following technical effects or advantages.

A technical means is used, where a client module in an electronic device initiates a first request to a server, the client module receives a packet that is generated by the server based on the first request and that is returned by the server, where the packet includes an entity data part corresponding to the first request, when it is determined that the entity data part of the packet is a download resource, the client module writes the download resource into a first storage area of the electronic device, the client module notifies a download management module in the electronic device, and the download management module reads the download resource from the first storage area, and stores the download resource into a second storage area of the electronic device. It can been seen that, in the present disclosure, data returned by the server is stored into the first storage area, and the download management module is instructed to retrieve the required entity data part from the first storage area, to implement download of the download resource into the second storage area. During an entire download process, the electronic device only needs to initiate one request to the server, and the server can obtain the download resource by making only one response, therefore, network load is reduced, and a problem of a traffic waste is avoided.

BRIEF DESCRIPTION OF DRAWINGS

FIG. 1 is an architecture diagram of an electronic device according to an embodiment of the present disclosure.

FIG. 2 is a flowchart of a resource download method according to an embodiment of the present disclosure.

FIG. 3A is a schematic interaction diagram of a preferred implementation manner of a resource download method according to an embodiment of the present disclosure.

FIG. 3B is an interaction flowchart of a resource download method according to an embodiment of the present disclosure.

FIG. 4 is a block diagram of an electronic device that implements resource download according to an embodiment of the present disclosure.

DESCRIPTION OF EMBODIMENTS

To resolve technical problems of increased network load and a traffic waste that are caused by a resource download solution in other approaches, embodiments of the present disclosure provide a resource download method, an electronic device, and an apparatus.

To make the objectives, technical solutions, and advantages of the embodiments of the present disclosure clearer, the following clearly and completely describes the technical solutions in the embodiments of the present disclosure with reference to the accompanying drawings in the embodiments of the present disclosure. The described embodiments are some but not all of the embodiments of the present disclosure. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments of the present disclosure without creative efforts shall fall within the protection scope of the present disclosure.

In the following, preferred implementation manners of the present disclosure are described in detail with reference to the accompanying drawings.

As shown in FIG. 1, FIG. 1 is an architecture diagram of an electronic device according to an embodiment of the present disclosure, where the electronic device includes an upper-layer application module 10, a processor 20 that supports the upper-layer application module 10, a first storage area 30, and a second storage area 40. Further, the upper-layer application module 10 includes a client module 101, a download management module 102, and a cache service module 103. Further, the client module 101 may be a browser module, an instant messaging module, and the like. The electronic device may be an Android system-based electronic device, such as an Android smartphone and an Android tablet computer. However, a procedure provided in this embodiment of the present disclosure is applied not only to the electronic device of an Android system.

Referring to FIG. 2, an embodiment of the present disclosure provides a resource download method, which may be applied to an electronic device shown in FIG. 1, and the resource download method includes the following procedure.

S101. A client module in an electronic device initiates a first request to a server.

Further, the first request is used to request to obtain a resource from the server. In a specific implementation process, the first request may be a “GET request” in the HTTP protocol. Certainly, in another protocol, the first request may also be a request that is in another form and that is used to obtain a resource from a network side. The first request includes a URL of an electronic device resource. The server finds, from the Internet according to the URL, a resource located by the URL.

S102. The client module receives a packet that is generated by the server based on the first request and that is returned by the server, where the packet includes an entity data part corresponding to the first request.

Further, the returned packet includes packet header information and the entity data part corresponding to the first request. The server first returns the packet header information of the packet, where two fields “Content-Type” and “Content-Disposition” in the packet header information are used to indicate a resource type of the entity data part, that is, whether the entity data part is a download resource, a web page resource, or the like.

S103. When it is determined that the entity data part of the packet is a download resource, the client module writes the download resource into a first storage area of the electronic device.

Further, the electronic device further includes a cache service module, and the client module writes the download resource into the first storage area using the cache service module. In a specific implementation process, the first storage area is a cache area, such as a random access memory (RAM) storage unit.

Further, before receiving the entity data part of the packet, the client module has received the packet header information, and determines, according to the two fields “Content-Type” and “Content-Disposition” in the packet header information, that the entity data part is a download resource. The first request may be a “GET request” in the HTTP protocol. Certainly, in another protocol, the first request may also be a request that is in another form and that is used to obtain a resource from the network side. When the entity data part of the packet is a web page resource, the client module receives the entity data part, and directly loads the entity data part as a web page.

In a specific implementation process, to enable the download management module to find a correct download resource in the cache service module, identification information used to identify the download resource is generated according to the URL of the download resource, to index the download resource written into the first storage area. Further, there are multiple manners of generating the identification information used to identify the download resource, and a first implementation manner of generating the identification information is that the URL and an identifier of the cache service module jointly form the identification information, for example, if the URL of the download resource is “http://finance.chinanews.com/it/5983282.shtml”, and the identifier of the cache service module is “HC-100A”, the identification information that is of the download resource and is in the cache service module may be “http://127.0.0.1/HC-100A/finance.chinanews.com/it/5983282.shtml”. Certainly, a person skilled in the art may know another form of forming the identification information according to the cache service module and the URL. A second implementation manner of generating the identification information is that the identification information may also be generated by adding, according to a sequence in which the download resource is written into the first storage area, a sequence number for the download resource, for example, formed identification information “URL1, URL2, URL3 . . . ” are sequentially “http://www.so.com//shehui/.shtml . . . 1”, “http://www.so.com/ . . . 2”, “http://www.docin.com/search . . . 3”, and the like. Certainly, in a specific implementation process, a person skilled in the art may know another form of forming the identification information according to the URL and the sequence in which the download resource is written into the first storage area, and further know that identification information of a location that is of the download resource and is in the cache service module may be indicated by adding other information to the URL, which are not illustrated one by one herein.

Further, to ensure that the download management module can correctly read the entity data part, which is written into the first storage area using the cache service module, a manner in which the client writes the entity data part into the download management module is a blocking mode (writing in the blocking mode means that when the first storage area corresponding to the cache service module is full, another entity data part waits to be written).

S104. The client module notifies a download management module in the electronic device, the download management module reads the download resource from the first storage area, and stores the download resource into a second storage area of the electronic device. Further, the second storage area is a storage area different from the first storage area, and may refer to a read-only memory (ROM) storage area.

Further, S104 includes Step 1: The client module generates first identification information according to the packet header information and the uniform resource locator URL of the download resource.

Further, the client module generates, according to the URL of the download resource, the first identification information that indicates the location that is of the download resource and is in the cache service module and a resource detail, where the resource detail is at least one of resource details, such as a resource data volume, a modified time, and a size, that are represented by at least one field in the packet header information. In a specific implementation process, for a manner of generating, by the client module, the first identification information according to the URL, refer to the foregoing implementation manner of generating the identification information used to index the download resource in the first storage area. For brevity of the specification, details are not described herein again.

Step 2: The client module writes the first identification information into a download record database associated with the download management module, where the first identification information is used by the download management module to obtain a download request corresponding to the download resource.

Step 3: The download management module responds to the download request, and queries, in the cache service module, identification information that matches the first identification information, where the download resource is indexed in the cache service module using second identification information.

Further, when detecting the download request, the download management module retrieves a download record corresponding to the obtained download request, and performs matching between the second identification information in the download record and at least one piece of identification information in the cache service module, to check whether the second identification information matches the first identification information.

Step 4: The download resource is indexed in the cache service module using the second identification information. When finding the second identification information that matches the first identification information, the download management module reads, from the first storage area using the cache service module, the download resource corresponding to the second identification information.

Further, the download management module communicates with the cache service module using a socket. In a specific implementation process, when the download management module finds, in the cache service module, the second identification information that matches the first identification information, the cache service module establishes socket communication with the download management module. Then, the download management module initiates, to the cache service module, a request used to request to send the download resource to the download management module. This request for requesting data may be a GET request in the HTTP protocol. The cache service module responds to the GET request that the download management module initiates to the cache service module, the cache service module reads the download resource from the first storage area, and returns the download resource to the download management module. In a specific implementation process, writing between the client module and the download management module is performed in the blocking mode. Correspondingly, the download management module reads the download resource in the blocking mode from the first storage area (reading in the blocking mode means that when the first storage area corresponding to the cache service module is empty, the cache service module waits to read an entity data part that has not been written into the first storage area). In a practical application, an abnormal case such as network disconnection may exist in a download process, therefore, combined use of writing in the blocking mode and reading in the blocking mode can ensure accuracy of an entire process in which a download resource reaches the first storage area from a network side by passing the client module, and then reaches the second storage area from the first storage area by passing the download management module, thereby avoiding interruption or an error of the download resource.

In other approaches, a download resource requested by a client needs to be downloaded using the download management module. So called user agent (UserAgent) refers to information such as a type and a version number that are of the client or the download management module, an operating system used by the client or the download management module, and a version number of the operating system thereof. However, UserAgent of the client may be different from UserAgent of the download management module. In addition, some existing servers can identify only UserAgent of the client, and therefore can respond to only a request sent by the client, however, when the request is sent again to a same server using the download management module, the server makes no response, which causes a failure in downloading the download resource requested using the client.

However, in the technical solution in this embodiment of the present disclosure, the client module only needs to initiate the first request to the server, therefore, even if the server does not support UserAgent of the download management module, a problem that the download resource requested using the client cannot be downloaded because the server is incompatible with UserAgent of the client module and that of the download management module at the same time can be avoided, thereby increasing a probability of successful resource download.

Preferably, to further increase a probability of successful resource download in the technical solution in this embodiment of the present disclosure, after the client module writes the identification information into the download management module, the following procedure is further provided in this embodiment of the present disclosure. When the download management module fails to find, in the cache service module, the identification information that matches the first identification information, the URL is determined from the first identification information, where the URL is used by the server to obtain the download resource, the download management module sends a second request according to the URL, where the second request is used to request the server to return the download resource to the download management module.

Further, the second request may be a GET request in the HTTP protocol, or may be a request that is in another form in another protocol and that is used to request data from the Internet. In addition, according to the foregoing rule of generating the identification information based on the URL, conversely, a person skilled in the field may know how to parse, from the identification information, the required URL of the download resource. For brevity of the specification, details are not described herein again.

In the following, an example in which the client is a browser, the server is a WEB server, and data transmission is performed based on the HTTP protocol is used to describe the technical solution in this embodiment of the present disclosure with reference to FIG. 3, however, the present disclosure is not limited thereto.

S1. The browser sends a GET request to the WEB server, where the GET request includes a URL of a resource required by the browser, and the GET request is used to request the WEB server to put, into an entity data part of an HTTP response packet, the resource located by the URL, to return to the browser.

S2. The WEB server returns packet header information to the browser.

S3. The browser parses a “Content-Disposition” field and a “Content-Type” field to determine whether the entity data part that needs to be currently received is a download resource.

If the entity data part is a web page resource, S4 is executed, that is, the browser receives the entity data part and loads the entity data part to a display page of the browser.

If the entity data part is a download resource, S5 to S8 are executed.

S5. The browser writes, in a blocking mode, the received entity data part into a first storage area using a cache service module, and indexes, using generated second identification information, the download resource written into the first storage area.

S6. The browser generates first identification information by packaging the packet header information and the URL of the download resource, and writes the first identification information into a download record database of a download management module such that the download management module detects a new download request. In a specific implementation process, S5 and S6 may be two independently executed steps, and there is no sequence in between.

S7. When detecting a new download request, the download management module retrieves a download record from the download record database, and queries, in the cache service module, identification information that matches the first identification information.

S8. When finding a second location identifier that matches the first identification information, the download management module establishes socket communication with the cache service module, reads, in the blocking mode, the download resource from the first storage module using the cache service module, and stores the download resource into a second storage area.

Based on a same disclosure idea, an embodiment of the present disclosure further provides an electronic device. Referring to FIG. 4, the electronic device includes a first sending unit 301 configured to control a client module in the electronic device to initiate a first request to a server, a receiving unit 302 configured to control the client module to receive a packet that is generated by the server based on the first request and that is returned by the server, where the packet includes an entity data part corresponding to the first request, a write unit 303 configured to, when determining that the entity data part of the packet is a download resource, control the client module to write the download resource into a first storage area of the electronic device, and a read unit 304 configured to control the client module to notify a download management module in the electronic device, and control the download management module to read the download resource from the first storage area and store the download resource into a second storage area of the electronic device.

Preferably, when the electronic device further includes a cache service module, the write unit 303 is configured to control the client module to write, using the cache service module, the download resource into the first storage area, and the read unit 304 is configured to control the download management module to read, using the cache service module, the download resource from the first storage area, and control the download management module to store the download resource into the second storage area.

Preferably, the packet further includes packet header information, and the write unit 303 is configured to, when the client module receives the packet header information, determine whether the entity data part is a download resource according to the packet header information, when determining that the entity data part is a download resource, control the client module to receive the entity data part, and control the client module to write, using the cache service module, data of the received entity data part into the first storage area such that the client module writes the download resource into the first storage area.

Preferably, the write unit 303 is further configured to control the client module to generate, according to the packet header information and a uniform resource locator URL of the download resource, first identification information, and control the client module to write the first identification information into a download record database associated with the download management module, where the first identification information is used by the download management module to obtain a download request corresponding to the download resource.

Preferably, the read unit 304 is configured to control the download management module to respond to the download request, and query, in the cache service module, identification information that matches the first identification information, where the download resource is indexed in the cache service module using second identification information, and when the download management module finds the second identification information that matches the first identification information, control the download management module to read, from the first storage area using the cache service module, the download resource corresponding to the second identification information.

Preferably, the electronic device further includes a determining unit configured to: when the download management module fails to find, in the cache service module, the identification information that matches the first identification information, determine the URL from the first identification information, where the URL is used by the server to obtain the download resource, and a second sending unit configured to control the download management module to send, according to the URL, a second request to the server, where the second request is used to request the server to return the download resource to the download management module.

One or more embodiments provided in the present disclosure may implement the following technical effects.

A technical means is used, where a client module in an electronic device initiates a first request to a server, the client module receives a packet that is generated by the server based on the first request and that is returned by the server, where the packet includes an entity data part corresponding to the first request, when it is determined that the entity data part of the packet is a download resource, the client module writes the download resource into a first storage area of the electronic device, the client module notifies a download management module in the electronic device, and the download management module reads the download resource from the first storage area, and stores the download resource into a second storage area of the electronic device. It can been seen that, in the present disclosure, data returned by the server is stored into the first storage area, and the download management module is instructed to retrieve the required entity data part from the first storage area, to implement download of the download resource into the second storage area. During an entire download process, the electronic device only needs to initiate one request to the server, and the server can obtain the download resource by making only one response, therefore, network load is reduced, and a problem of a traffic waste is avoided.

A person skilled in the art should understand that the embodiments of the present disclosure may be provided as a method, a system, or a computer program product. Therefore, the present disclosure may use a form of hardware only embodiments, software only embodiments, or embodiments with a combination of software and hardware. Moreover, the present disclosure may use a form of a computer program product that is implemented on one or more computer-usable storage media (including but not limited to a disk memory, a computer disc read only memory (CD-ROM), an optical memory, and the like) that include computer-usable program code.

The present disclosure is described with reference to the flowcharts and/or block diagrams of the method, the device (system), and the computer program product according to the embodiments of the present disclosure. It should be understood that computer program instructions may be used to implement each process and/or each block in the flowcharts and/or the block diagrams and a combination of a process and/or a block in the flowcharts and/or the block diagrams. These computer program instructions may be provided for a general-purpose computer, a dedicated computer, an embedded processor, or a processor of any other programmable data processing device to generate a machine such that the instructions executed by a computer or a processor of any other programmable data processing device generate an apparatus for implementing a specific function in one or more processes in the flowcharts and/or in one or more blocks in the block diagrams.

These computer program instructions may also be stored in a computer readable memory that can instruct the computer or any other programmable data processing device to work in a specific manner such that the instructions stored in the computer readable memory generate an artifact that includes an instruction apparatus. The instruction apparatus implements a specific function in one or more processes in the flowcharts and/or in one or more blocks in the block diagrams.

These computer program instructions may also be loaded onto a computer or another programmable data processing device such that a series of operations and steps are performed on the computer or the other programmable device, thereby generating computer-implemented processing. Therefore, the instructions executed on the computer or the other programmable device provide steps for implementing a specific function in one or more processes in the flowcharts and/or in one or more blocks in the block diagrams.

Although some preferred embodiments of the present disclosure have been described, persons skilled in the art can make changes and modifications to these embodiments once they learn the basic inventive concept. Therefore, the following claims are intended to be construed as to cover the preferred embodiments and all changes and modifications falling within the scope of the present disclosure.

Obviously, persons skilled in the art can make various modifications and variations to the embodiments of the present disclosure without departing from the spirit and scope of the embodiments of the present disclosure. The present disclosure is intended to cover these modifications and variations provided that they fall within the scope of protection defined by the following claims and their equivalent technologies. 

What is claimed is:
 1. A resource download method implemented by an electronic device, the method comprising: initiating sending a first request to a server; receiving, from the server, a packet responsive to the first request, wherein the packet comprises an entity data part corresponding to the first request; writing, using a cache servicer of the electronic device, a resource to be downloaded into a first storage area of the electronic device when the entity data part of the packet includes the resource to be downloaded; writing, to a download record database of a download manager in the electronic device, first identification information corresponding to the packet; querying, by the download manager, the cache servicer for second identification information that matches the first identification information; and when the download manager fails to find, in the cache servicer, the second identification information: determining, based on the first identification information, a uniform resource locator (URL) of the resource to be downloaded; and sending, by the download manager to the server according to the URL, a second request that requests the server to return the resource to be downloaded to the download manager.
 2. The resource download method of claim 1, wherein reading the resource to be downloaded from the first storage area comprises reading, by the download manager, the resource to be downloaded from the first storage area using the cache servicer.
 3. The resource download method of claim 2, wherein the packet further comprises packet header information, wherein the method further comprises determining whether the entity data part includes the resource to be downloaded according to the packet header information, and wherein writing the resource to be downloaded into the first storage area comprises writing data of the entity data part into the first storage area using the cache servicer when the entity data part includes the resource to be downloaded.
 4. The resource download method of claim 3, further comprising generating the first identification information according to the packet header information and the URL.
 5. The resource download method of claim 4, further comprising indexing the resource to be downloaded in the cache servicer using the second identification information, and wherein reading the resource to be downloaded from the first storage area comprises reading, by the download manager, the resource to be downloaded when the download manager finds the second identification information.
 6. The resource download method of claim 1, wherein the first request is a GET request in a hypertext transfer protocol (HTTP).
 7. The resource download method of claim 1, wherein the first storage area is a random access memory (RAM).
 8. An electronic device, comprising: a transmitter configured to send a first request to a server; a receiver coupled to the transmitter and configured to receive, from the server, a packet responsive to the first request, wherein the packet comprises an entity data part corresponding to the first request; and a processor coupled to the receiver and the transmitter and configured to: write, using a cache servicer of the electronic device, a resource to be downloaded into a first storage area of the electronic device when the entity data part of the packet includes the resource to be downloaded; write first identification information corresponding to the packet to a download record database of a download manager in the electronic device; control the download manager to query the cache servicer for second identification information that matches the first identification information; and when the download manager fails to find, in the cache servicer, the second identification information: control the download manager to determine a uniform resource locator (URL) of the resource to be downloaded based on the first identification information; and control the download manager to send, to the server according to the URL, a second request that requests the server to return the resource to be downloaded to the download manager.
 9. The electronic device of claim 8, wherein the processor is configured to control the download manager to read the resource to be downloaded from the first storage area using the cache servicer.
 10. The electronic device of claim 9, wherein the packet further comprises packet header information, and wherein the processor is further configured to: determine, according to the packet header information, whether the entity data part includes the resource to be downloaded; and write, using the cache servicer, data of the entity data part into the first storage area when the entity data part includes the resource to be downloaded.
 11. The electronic device of claim 10, wherein the processor is further configured to generate the first identification information according to the packet header information and the URL of the resource to be downloaded.
 12. The electronic device of claim 11, wherein the processor is further configured to: index the resource to be downloaded in the cache servicer using the second identification information; and control the download manager to read the resource to be downloaded when the download manager finds the second identification information.
 13. The electronic device of claim 8, wherein the first request is a GET request in a hypertext transfer protocol (HTTP).
 14. The electronic device of claim 8, wherein the first storage area is a random access memory (RAM).
 15. A resource download method implemented by an electronic device, the method comprising: sending, by a web browser in the electronic device, a first request to a server; receiving, by the web browser from the server, a packet responsive to the first request, wherein the packet comprises packet header information and an entity data part corresponding to the first request; loading, by the web browser, a web page resource when the entity data part includes the web page resource; writing, by the web browser, a resource to be downloaded that does not include the web page resource into a first storage area of the electronic device when the entity data part includes the resource to be downloaded; writing, by the web browser, first identification information corresponding to the resource to be downloaded in a download record database of a download manager of the electronic device; retrieving, by the download manager from the download record database, the first identification information; using, by the download manager, the first identification information to obtain the resource to be downloaded from the first storage area; and storing, by the download manager, the resource to be downloaded into a second storage area of the electronic device.
 16. The resource download method of claim 15, further comprising generating the first identification information according the packet header information and a uniform resource locator (URL) of the resource to be downloaded.
 17. The resource download method of claim 16, wherein the download manager uses a cache servicer to obtain the resource to be downloaded from the first storage area.
 18. The resource download method of claim 17, wherein the method further comprises determining, by the web browser, whether the entity data part includes the resource to be downloaded according to the packet header information when the electronic device receives the packet header information, and wherein writing the resource to be downloaded into the first storage area comprises writing, by the web browser, data of the entity data part into the first storage area using the cache servicer when the entity data part includes the resource to be downloaded.
 19. The resource download method of claim 18, further comprising indexing the resource to be downloaded in the cache servicer using second identification information, and wherein using the first identification information to obtain the resource to be downloaded from the first storage area comprises reading, by the download manager, the resource to be downloaded when the download manager finds the second identification information.
 20. The resource download method of claim 15, wherein the first request is a GET request in a hypertext transfer protocol (HTTP). 